package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 考核细项打分结果
 *
 * @author ytche
 * @date 2017年8月9日
 *
 */
@Entity
@Table(name = "tnb_assessment_indicator_result")
@JsonApiResource(type = "assessmentIndicatorResult")
public class AssessmentIndicatorResult extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private Assessment assessment;
	private AssessmentIndicator assessmentIndicator;
	private Integer score;

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.SELECT)
	@JoinColumn(name = "assessment_id")
	public Assessment getAssessment() {
		return assessment;
	}

	public void setAssessment(Assessment assessment) {
		this.assessment = assessment;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "indicator_id")
	public AssessmentIndicator getAssessmentIndicator() {
		return assessmentIndicator;
	}

	public void setAssessmentIndicator(AssessmentIndicator assessmentIndicator) {
		this.assessmentIndicator = assessmentIndicator;
	}

	@Column(name = "score")
	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

}
